package tmproject.hlhj.fhp.cartrans.modules

import android.content.Context
import com.example.mymvp.BaseModule
import com.lzy.okgo.model.HttpParams
import com.lzy.okgo.model.Response
import tmproject.hlhj.fhp.cartrans.http.Apis
import tmproject.hlhj.fhp.cartrans.http.BaseObserver
import tmproject.hlhj.fhp.cartrans.http.LoadingAction
import tmproject.hlhj.fhp.cartrans.javaBean.BaseBean

/**
 * Created by Administrator on 2018/8/28/028.
 */
class IdentifyModule :BaseModule {
    var listener:OnIdentifyListener?=null
    fun getIdentify(c:Context){
        listener?.setIDentify()
    }

    fun changeInfo(c: Context,params: HttpParams){
        Apis.changeInfo(params)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :BaseObserver<Response<BaseBean>>(c){
                                override fun failed(e: Throwable?) {
                                }

                                override fun httpSuccess(t: Response<BaseBean>) {
                                    listener?.changeInfo(t.body())
                                }

                                override fun httpErroCode(baseBean: BaseBean) {
                                }
                            })
                }
    }

    interface OnIdentifyListener{
        fun setIDentify()
        fun changeInfo(baseBean: BaseBean)
    }
}